home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr09 / vstsrc.zip / MAPADJ.C < prev    next >
C/C++ Source or Header  |  1995-01-23  |  8KB  |  200 lines

  1. /*
  2.  * %W% %E% %U%  [EXTREL_1.2]
  3.  *
  4.  * VersaTrack orbit calculations are based on those that appear in Dr. Manfred
  5.  * Bester's sattrack program (the Unix(tm) versions 1 and 2).
  6.  *
  7.  * The data from which the maps where generated come from "xsat", an
  8.  * X-Windows program by David A. Curry (N9MSW).
  9.  *
  10.  * Site coordinates come from various sources, including a couple of
  11.  * World Almanacs, and also from both of the programs mentioned above.
  12.  *
  13.  * The following are authors' applicable copyright notices:
  14.  *
  15.  *                                                                               
  16.  * Copyright (c) 1992, 1993, 1994 Manfred Bester. All Rights Reserved.        
  17.  *                                                                           
  18.  * Permission to use, copy, modify, and distribute this software and its      
  19.  * documentation for educational, research and non-profit purposes, without   
  20.  * fee, and without a written agreement is hereby granted, provided that the  
  21.  * above copyright notice and the following three paragraphs appear in all    
  22.  * copies.                                                                    
  23.  *                                                                              
  24.  * Permission to incorporate this software into commercial products may be    
  25.  * obtained from the author, Dr. Manfred Bester, 1636 M. L. King Jr. Way,     
  26.  * Berkeley, CA 94709, USA.                                                   
  27.  *                                                                             
  28.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,  
  29.  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF    
  30.  * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED   
  31.  * OF THE POSSIBILITY OF SUCH DAMAGE.                                         
  32.  *                                                                             
  33.  * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT       
  34.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A    
  35.  * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"       
  36.  * BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,  
  37.  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.                                   
  38.  *                                                                             
  39.  *                                                                             
  40.  * Copyright 1992 by David A. Curry                                            
  41.  *                                                                             
  42.  * Permission to use, copy, modify, distribute, and sell this software and its 
  43.  * documentation for any purpose is hereby granted without fee, provided that  
  44.  * the above copyright notice appear in all copies and that both that copyright
  45.  * notice and this permission notice appear in supporting documentation.  The  
  46.  * author makes no representations about the suitability of this software for  
  47.  * any purpose.  It is provided "as is" without express or implied warranty.   
  48.  *                                                                             
  49.  * David A. Curry, N9MSW                                                       
  50.  * Purdue University                                                           
  51.  * Engineering Computer Network                                                
  52.  * 1285 Electrical Engineering Building                                        
  53.  * West Lafayette, IN 47907                                                    
  54.  * davy@ecn.purdue.edu                                                         
  55.  *                                                                             
  56.  * VersaTrack Copyright (c) 1993, 1994 Siamack Navabpour. All Rights Reserved.
  57.  *
  58.  * Permission is hereby granted to copy, modify and distribute VersaTrack
  59.  * in whole, or in part, for educational, non-profit and non-commercial use
  60.  * only, free of charge or obligation, and without agreement, provided that
  61.  * all copyrights and restrictions noted herein are observed and followed, and
  62.  * additionally, that this and all other copyright notices listed herein
  63.  * appear unaltered in all copies and in all derived work.
  64.  *
  65.  * This notice shall not in any way void or supersede any of the other authors
  66.  * rights or privileges.
  67.  *
  68.  * VersaTrack IS PRESENTED FREE AND "AS IS", WITHOUT ANY WARRANTY OR SUPPORT.
  69.  * YOU USE IT AT YOUR OWN RISK. The author(s) shall not be liable for any
  70.  * direct, indirect, incidental, or consequential damage, loss of profits or
  71.  * other tangible or intangible losses or benefits, arising out of or related
  72.  * to its use. VersaTrack carries no warranty, explicit or implied, including
  73.  * but not limited to those of merchantablity and fitness for a particular
  74.  * purpose.
  75.  *
  76.  * Siamack Navabpour, 12342 Hunter's Chase Dr. Apt. 2114, Austin, TX 78729.
  77.  * sia@bga.com or sia@realtime.com.
  78.  */
  79.  
  80. /*
  81.  * Utility to fix the raw maps.
  82.  * This program is part of VersaTrack package.
  83.  * Copyright (c) 1994 Siamack Navabpour. All Rights Reserved.
  84.  */
  85.  
  86. #include <windows.h>
  87. #include <stdio.h>
  88. #include <math.h>
  89.  
  90. #include "vstdefs.h"
  91. #include "vsttype.h"
  92. #include "vstextrn.h"
  93. #include "vstdib.h"
  94.  
  95. #undef  MIN
  96. #define MIN(x,y)    (((x) < (y) ) ? (x) : (y))
  97. #define BLEN        (16*1024)
  98. #define NMAPS       6
  99.  
  100. char buf[BLEN];
  101. mapdata_t md[NMAPS];
  102. OFSTRUCT sof,dof;
  103.  
  104. static char *mapname1[NMAPS] = {
  105.     "world86.dib", "usa86.dib", "world64.dib", "usa64.dib",
  106.     "world14.dib", "usa14.dib",
  107. };
  108.  
  109. static char *mapdesig[NMAPS] = {
  110. "world86", "usa86", "world64", "usa64", "world14", "usa14",
  111. };
  112.  
  113. static void fatal(char *s) { printf("%s\n", s); exit(1); }
  114.  
  115. int
  116. main(ac,av)
  117. char *av[];
  118. {
  119.     HANDLE sfp;
  120.     HANDLE dfp;
  121.     int r, which;
  122.     char outname[100];
  123.     
  124.     if (ac < 2)
  125.         fatal("must specify maptype: world86, usa86, world64 or usa64");
  126.  
  127.     for (which = -1, r=0; r < NMAPS; r++) {
  128.         if (strcmp(av[1], mapdesig[r]) == 0) {
  129.            which = r;
  130.            break;
  131.         }
  132.     }
  133.     if (which < 0)
  134.         fatal("invalid map designator");
  135.  
  136.     sfp = (HANDLE) OpenFile((void *)mapname1[which], &sof, (UINT) OF_READ);
  137.     if (sfp == INVALID_HANDLE_VALUE)
  138.         fatal("cannot open input .raw file for reading");
  139.  
  140.     sprintf(outname, "%s.map", mapdesig[which]);
  141.     dfp = (HANDLE) OpenFile((void *)outname, &dof, (UINT)(OF_CREATE|OF_WRITE));
  142.  
  143.     if (dfp == INVALID_HANDLE_VALUE)
  144.         fatal("cannot create/open .dib file for writing");
  145.  
  146.     printf("creating %s from %s", outname, mapname1[which]);
  147.     do {
  148.         r =_lread((int)sfp, (LPSTR)buf, BLEN);
  149.         if (r > 0) {
  150.             if (_lwrite((int)dfp, (LPSTR)buf, r) != r)
  151.             fatal("write error");
  152.         }
  153.         printf(".");
  154.     } while (r > 0);
  155.  
  156.     CloseHandle(sfp);
  157.  
  158.     md[0].m_version = VSTVERSION;
  159.     md[1].m_version = VSTVERSION;
  160.     md[2].m_version = VSTVERSION;
  161.     md[3].m_version = VSTVERSION;
  162.  
  163.     /* USA86 */
  164.     md[1].m_RFU0 = 0;
  165.     md[1].m_minx = -126.137259;
  166.     md[1].m_miny = -49.952297; /* min & max inverted in sign and position */
  167.     md[1].m_maxx = -65.555641;
  168.     md[1].m_maxy = -24.561303;
  169.  
  170.     /* USA64 */
  171.  
  172.     md[3].m_RFU0 = 0;
  173.     md[3].m_minx = - 126.523950;
  174.     md[3].m_miny = -  50.038336;  /* min & max inverted in sign and position */
  175.     md[3].m_maxx = -  65.168950;
  176.     md[3].m_maxy = -  24.475264;
  177.  
  178.     /* World86 */
  179.     md[0].m_RFU0 = 0;
  180.     md[0].m_minx = -189.653172;
  181.     md[0].m_miny =  -88.593801;
  182.     md[0].m_maxx =  199.683172;
  183.     md[0].m_maxy =   88.641801;
  184.  
  185.     /* World64 */
  186.     md[2].m_RFU0 = 0;
  187.     md[2].m_minx = -192.564195;
  188.     md[2].m_miny = - 89.194373;
  189.     md[2].m_maxx = 201.394195;
  190.     md[2].m_maxy = 89.242373;
  191.  
  192.  
  193.     if (_lwrite((int)dfp, (LPSTR) &md[which], sizeof(md)) != sizeof(md))
  194.         fatal("write error");
  195.  
  196.     CloseHandle(dfp);
  197.     printf(" done.\n");
  198.     exit(0);
  199. }
  200.